<template>
  <div class="productDetail mui-content">
    <!-- 轮播图 -->
    <swiper height="87vw" :list="dataJson.advert_info" auto></swiper>

    <div class="profooterContainer">
      <!-- 价格 -->
      <div class="proCenterContainer">
        <div class="proDetailtitle">
          <span>{{dataJson.shop_name}}</span>
        </div>
        <div class="proPrice">
          <span class="presentPrice">¥ {{dataJson.goods_info.sale_price}}</span>
          <del class="oldPrice">¥ {{dataJson.goods_info.market_price}}</del>
          <p class="pro_num"></p>
        </div>
      </div>
      <!-- 评论 -->
      <div class="commentBox">
        <li class="mui-table-view-cell tableItem" id="viewComment" style="margin-bottom: 0;">
          <span class="mui-navigate-right">评论</span>
        </li>
        <!-- 评论列表 -->
        <div class="comment" id="commentParent">
          <li v-for="commentItem in dataJson.commentList" :key="commentItem.shop_goods_id" class="mui-table-view-cell tableItem">
            <div class="iconTx">
              <img :src="dealImg(commentItem.head_portrait)">
              <p class="name">{{commentItem.nickname}}</p>
            </div>
            <div class="commentText">
              <p class="text over2">{{commentItem.appraise_content}}</p>
              <p class="size">尺寸：小脚紧身 </p>
              <span class="time">{{commentItem.appraise_time.substring(0,16)}}</span>
            </div>
            <div class="commentImgList">
              <img :src="dealImg(commentItem.appraise_pic)" data-preview-src="" data-preview-group="1">
            </div>
          </li>
        </div>
        <!-- 评论结束 -->
      </div>
      <!-- 店铺信息 -->
      <div class="storeNameContainer">
        <li shop_id="16" class="mui-table-view-cell storeNameItem">
          <a class="mui-navigate-right" style="display: flex;align-content: flex-start; align-items: center;margin:0;width:100%;">
            <div class="storeIcon">
              <img :src="dataJson.imgUrl">
            </div>
            <div class="storeText">
              <p class="name">{{dataJson.goods_info.shop_info_name}}</p>
            </div>
          </a>
        </li>
        <div class="listItems">
          <dl class="listItemBox">
            <dt></dt>
            <dd class="IconTx">
              <p>
                <span class="listItemNum">{{dataJson.shop_info.hidegoods_amount}}</span>
              </p>
              <p>全部宝贝</p>
            </dd>
          </dl>
          <dl class="listItemBox">
            <dt></dt>
            <dd class="wy_tx">
              <p>
                <span class="listItemNum">{{dataJson.goods_info.sales_amount}}</span>
              </p>
              <p>卖出宝贝</p>
            </dd>
          </dl>
          <dl class="listItemBox scoreBox">
            <dt></dt>
            <dd>
              <p class="scoreContainer">
                <span class="scoreText">宝贝描述</span>
                <span class="scoreNum">{{dataJson.shop_info.hidedescription_score}}</span>
              </p>
              <p class="scoreContainer">
                <span class="scoreText">卖家服务</span>
                <span class="scoreNum">{{dataJson.shop_info.hideservice_score}}</span>
              </p>
              <p class="scoreContainer">
                <span class="scoreText">跨境物流</span>
                <span class="scoreNum">{{dataJson.shop_info.hidematerial_flow_score}}</span>
              </p>
            </dd>
          </dl>
        </div>
      </div>
      <!-- 店铺信息结束 -->
      <section class="picDetail">
        <div class="picTip">
          <span>继续拖动，查看图文详情</span>
        </div>
        <div class="picBox">
          <iframe id="picBoxIframe" @load="iframeLoad" style="overflow: auto !important;width: 100%;" :src="dataJson.iframeUrl"></iframe>
        </div>
      </section>
      <!-- 图文详情结束 -->
    </div>
    <spinner v-show="dataJson.isActive" :type="'ripple'"></spinner>
  </div>

</template>
<script>
  import commonJson from '../../../static/js/common';
  import {
    Swiper,
    SwiperItem,
    Scroller,
    Spinner
  } from 'vux'
  export default {
    data() {
      return {
        dataJson: {
          advert_info: [],
          commentList: [],
          goods_info: {},
          shop_info: {},
          imgUrl: '',
          iframeUrl: '',
          isActive: true
        }
      }
    },
    beforeCreate() {

    },
    mounted() {
      console.log('params',this.$route.query)
      var that = this;
      that.axios.get(commonJson.commonData().domainName + '/api/zbds/goods/goodsInfo', {  //商品详情
          params: {
            shop_goods_id: this.$route.query.goods_id,
            token: commonJson.commonData().token
          }
        })
        .then(function (response) {
          console.log(response.data);
          if (response.data.code == 0) {
            that.dataJson.advert_info = that.processingFunction(response.data.data);
            that.dataJson.goods_info = response.data.data;
            that.dataJson.shop_info = response.data.data.shop_info;
            that.dataJson.imgUrl = commonJson.commonData().domainImgName + response.data.data.shop_info.head_portrait;
            that.dataJson.iframeUrl = commonJson.commonData().domainName + response.data.data.goods_description;
            that.dataJson.isActive = false;
          } else {

          }
        })
        .catch(function (err) {
          console.log(err);
        });

        that.axios.get(commonJson.commonData().domainName + '/api/v1/order/shopGoodsCommentList', {    //评价列表
          params: {
            pageSize: 10,
				  	pageIndex: 1,
				  	shop_goods_id: that.$route.query.goods_id
          }
        })
        .then(function (response) {
          console.log(response.data);
          if (response.data.code == 0) {
            if (response.data.data.rows > 2) {              
              that.dataJson.commentList = response.data.data.rows.slice(0,1);
            } else {            
              that.dataJson.commentList = response.data.data.rows;
            }
          } else {

          }
        })
        .catch(function (err) {
          console.log(err);
        });
    },
    components: {
      Swiper,
      SwiperItem,
      Scroller,
      Spinner
    },
    methods: {
      processingFunction: function (data) {
        var processObj = new Array(),
          picArray = data.pic.split(',');
        picArray.forEach(function (ele, i) {
          let object = {}
          processObj.push(Object.assign({}, object, { //数组中push对象
            img: commonJson.commonData().domainImgName + picArray[i],
            id: i,
            fallbackImg: 'https://static.vux.li/demo/3.jpg'
          }))
        }, this);
        return processObj;
      },
      iframeLoad: function (e) {
        var iframe = document.getElementById('picBoxIframe');
        iframe.height = iframe.contentWindow.document.documentElement.scrollHeight;
      },
      dealImg: function(param){
          if (param) {
            if(param.indexOf(',') != -1){
              param = param.split(',')[0];
              if(param.indexOf('zhibodianshang/upload/') != -1) {
                return domainImgName + param.split('zhibodianshang/upload')[1];
              } else if(param.indexOf('putaotang/upload') != -1) {
                return domainImgName + param.split('putaotang/upload')[1];
              } else if(param.indexOf('http') != -1) {
                return param;
              } else {
                return commonJson.commonData().domainImgName + param;
              }
            }else{
              if(param.indexOf('zhibodianshang/upload/') != -1) {
                return domainImgName + param.split('zhibodianshang/upload')[1];
              } else if(param.indexOf('putaotang/upload') != -1) {
                return domainImgName + param.split('putaotang/upload')[1];
              } else if(param.indexOf('http') != -1) {
                return param;
              } else {
                return commonJson.commonData().domainImgName + param;
              }		
            }
          }
      }
    }
  }

</script>
<style>
  html {
    font-size: 50px;
  }
  #app{
    padding-bottom: 0;
  }
  .productDetail .vux-spinner {
    width: 100%;
    height: 100%;
    position: fixed;
    background: rgba(255, 255, 255, 1);
    top: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    stroke: #4b8bf4;
    fill: #4b8bf4;
  }

  .productDetail .vux-spinner svg {
    width: 25vw;
    height: 25vw;
    color: #4b8bf4;
  }

</style>

<style scoped>
  .proCenterContainer {
    width: 100%;
    background-color: #FFFFFF;
    padding: 0.2rem;
  }

  .proCenterContainer .proDetailtitle {
    font-size: 14px;
    color: #333;
    margin-bottom: 0.2rem;
  }

  .proCenterContainer .proPrice {
    width: 100%;
  }

  .proCenterContainer .proPrice .presentPrice {
    font-size: 16px;
    color: #FE0000;
    font-weight: bold;
  }

  .proCenterContainer .proPrice .oldPrice {
    font-size: 14px;
    margin-left: 10px;
    color: #666666;
  }

  .proCenterContainer .proPrice p {
    margin-bottom: 0;
    font-size: 12px;
  }

  .tableItem {
    background-color: #FFFFFF;
    margin: 0.1rem 0 0.1rem 0;
    font-size: 13px;
  }

  .profooterContainer {
    width: 100%;
    /* padding-bottom: 50px; */
    overflow: hidden;
  }

  .comment {
    margin-bottom: 0.24rem;
    background-color: #fff;
  }

  .comment .mui-table-view-cell:last-child:after,
  .mui-table-view-cell:last-child:before {
    height: 1px;
  }

  .comment .tableItem {
    padding: 0.1rem 15px;
    margin: 0;
  }

  .comment .inputContainer {
    padding: 0.2rem;
    width: 100%;
    text-align: center;
  }

  .comment .inputContainer input {
    border: 1px solid #FF5001;
    color: #FF5001;
  }

  .commentImgList {
    width: 100%;
    margin-top: 0.15rem;
  }

  .commentImgList img {
    width: 1.2rem;
    height: 1.2rem;
    margin-right: 0.1rem;
  }

  .iconTx {
    width: 100%;
    position: relative;
    display: flex;
    align-content: center;
    align-items: center;
    justify-content: flex-start;
    margin-bottom: 5px;
    /*padding: 0.15rem 0.1rem 0.15rem 0.15rem;*/
  }

  .iconTx img {
    width: 30px;
    height: 30px;
    border-radius: 15px;
  }

  .commentText {
    width: 100%;
    /*padding-left: 0.2rem;*/
  }

  .iconTx .name {
    font-size: 12px;
    color: #999;
    margin-left: 8px;
  }

  .commentText .text {
    font-size: 12px;
    color: #666;
  }

  .commentText .size {
    font-size: 12px;
    color: #999;
  }

  .commentText .time {
    font-size: 12px;
    color: #999;
    position: absolute;
    top: 10px;
    right: 0.2rem;
  }

  .profooterContainer .storeNameContainer {
    width: 100%;
    padding: 0.3rem;
    background-color: #FFFFFF;
  }

  .profooterContainer .storeNameContainer .storeNameItem {
    width: 100%;
    padding: 0;
    margin: 0;
    display: flex;
    align-content: flex-start;
    align-items: center;
  }

  .profooterContainer .storeNameContainer .storeNameItem:after {
    height: 0;
  }

  .profooterContainer .storeNameContainer .storeNameItem .storeIcon {
    width: 60px;
    height: 60px;
  }

  .profooterContainer .storeNameContainer .storeNameItem .storeIcon img {
    width: 100%;
    height: 100%;
  }

  .profooterContainer .storeNameContainer .storeNameItem .storeText {
    width: 85%;
    padding-left: 0.3rem;
  }

  .profooterContainer .storeNameContainer .storeNameItem .storeText .name {
    font-size: 14px;
    color: #333333;
    margin-bottom: 0.3rem;
  }

  .profooterContainer .storeNameContainer .storeNameItem .storeText .text {
    font-size: 13px;
    color: #6ba1fe;
  }

  .profooterContainer .storeNameContainer .listItems {
    background: #fff;
    position: relative;
    margin-bottom: 0.2rem;
    display: flex;
    align-content: flex-start;
    align-items: center;
  }

  .profooterContainer .storeNameContainer .listItems .listItemBox {
    width: 30%;
    float: left;
    text-align: center;
    position: relative;
  }

  .profooterContainer .storeNameContainer .listItems .listItemBox.scoreBox {
    width: 40%;
  }

  .profooterContainer .storeNameContainer .listItems dl dd {
    margin-top: 0.14rem;
  }

  .profooterContainer .storeNameContainer .listItems .listItemBox dd p .listItemNum {
    font-size: 13px;
  }

  .profooterContainer .storeNameContainer .listItems dl dd p {
    color: #666;
    font-size: 12px;
    height: 0.4rem;
    text-align: center;
    margin-bottom: 0.3rem;
  }

  .profooterContainer .storeNameContainer .listItems dl dd p span {
    color: #666;
    font-size: 12px;
  }

  .profooterContainer .storeNameContainer .listItems dl dd .scoreContainer span {
    font-size: 12px;
  }

  .profooterContainer .storeNameContainer .listItems dl dd .scoreContainer {
    margin-bottom: 0.15rem;
  }

  .profooterContainer .storeNameContainer .listItems .listItemBox:after {
    position: absolute;
    right: 0;
    bottom: 0;
    width: 1px;
    height: 100%;
    content: '';
    -webkit-transform: scaleY(.8);
    transform: scaleY(.8);
    background-color: #c8c7cc;
  }

  .profooterContainer .storeNameContainer .listItems .scoreBox:after {
    height: 0;
  }

  .profooterContainer .storeNameContainer .listItems .scoreBox dd .scoreContainer .scoreText {
    margin-left: 0.26rem;
  }

  .profooterContainer .storeNameContainer .listItems .scoreBox dd .scoreContainer .scoreNum {
    margin-left: 0.1rem;
    color: #FF7038;
  }

  .profooterContainer .storeNameContainer .listItems .scoreBox dd .scoreContainer .scoreBg {
    margin-left: 0.1rem;
    color: #FFFFFF;
    background-color: #ff7c41;
    padding: 0.07rem;
  }

  .profooterContainer .storeNameContainer .contactUs {
    width: 100%;
    text-align: center;
  }

  .profooterContainer .storeNameContainer .contactUs input {
    border: 1px solid #FF7038;
    color: #FF7038;
    margin-left: 0.3rem;
  }

  .profooterContainer .picDetail {
    width: 100%;
  }

  .profooterContainer .picDetail .picTip {
    width: 100%;
    text-align: center;
    color: #666666;
    padding: 0.2rem 0rem;
    font-size: 12px;
    position: relative;
  }

  .profooterContainer .picDetail .picTip:before {
    position: absolute;
    left: 5%;
    top: 50%;
    width: 20%;
    height: 1px;
    content: '';
    -webkit-transform: scaleY(.8);
    transform: scaleY(.8);
    background-color: #c8c7cc;
  }

  .profooterContainer .picDetail .picTip:after {
    position: absolute;
    right: 5%;
    top: 50%;
    width: 20%;
    height: 1px;
    content: '';
    -webkit-transform: scaleY(.8);
    transform: scaleY(.8);
    background-color: #c8c7cc;
  }

  .profooterContainer .picDetail .picBox {
    width: 100%;
  }

  .profooterContainer .picDetail .picBox img {
    width: 100%;
  }

  .mui-bar.mui-bar-tab {
    display: flex;
    align-items: center;
    align-content: flex-start;
  }

  .mui-bar .barItem {
    width: 20%;
    text-align: center;
    font-size: 0.2rem;
    color: #999;
  }

  .mui-bar .barItem:first-child {
    border-right: solid 1px #eee;
  }

  .mui-bar .ShoppingCart {
    position: relative;
  }

  .mui-bar .ShoppingCart p {
    position: absolute;
    font: 10px/10px "microsoft yahei";
    color: #fff;
    top: -5px;
    right: 5px;
    text-align: center;
    background-color: #FF5001;
    width: 16px;
    height: 16px;
    padding: 3px 0;
    border-radius: 50%;
    display: none;
  }

  .mui-bar .Collection {}

  .mui-bar .joinItem {
    width: 30%;
    height: 100%;
    line-height: 50px;
    text-align: center;
    font-size: 13px;
    color: #666666;
    vertical-align: middle;
  }

  .mui-bar .joinCart {
    background-color: #fe9901;
    color: #fff;
  }

  .mui-bar .buyNow {
    background-color: #ff5001;
    color: #fff;
  }

  .mui-bar .barItem .iconfont {
    font-size: 0.45rem;
  }

  .mui-bar .barItem .text {
    display: block;
    font-size: 12px;
  }

  #popover {
    width: 100%;
    position: fixed;
    bottom: 0px;
    z-index: 999999;
  }

  #popover .popTopBox {
    width: 100%;
    padding: 0 0.2rem 0.2rem 0.2rem;
    position: relative;
    overflow: inherit;
    font-size: 14px;
  }

  #popover.mui-popover .mui-scroll .mui-table-view {
    overflow: inherit;
    background-color: #fff;
  }

  #popover .popTopBox p {
    font-size: 14px;
    line-height: 0.3rem;
    margin-left: 1.8rem;
  }

  #popover.mui-popover .mui-scroll .mui-table-view .mui-table-view-cell .proprice {
    color: #fe5100;
    margin-bottom: 10px;
  }

  #popover .popTopBox .popContainerIcon {
    position: absolute;
    width: 1.34rem;
    height: 1.34rem;
    top: -0.3rem;
    left: 0.25rem;
    border-radius: 0.3rem;
  }

  #popover .popTopBox .popContainerIcon img {
    width: 100%;
    height: 100%;
  }

  #popover.mui-popover .mui-scroll-wrapper {
    overflow: inherit;
  }

  #popover.mui-popover .mui-scroll .mui-table-view .mui-table-view-cell .btn {
    margin-right: 0.2rem;
    font-size: 14px;
    font-weight: 400;
    line-height: 1.42;
    position: relative;
    display: inline-block;
    margin-bottom: 0;
    padding: 6px 12px;
    cursor: pointer;
    -webkit-transition: all;
    transition: all;
    -webkit-transition-timing-function: linear;
    transition-timing-function: linear;
    -webkit-transition-duration: .2s;
    transition-duration: .2s;
    text-align: center;
    vertical-align: top;
    white-space: nowrap;
    color: #333;
    border: 1px solid #ccc;
    border-radius: 3px;
    border-top-left-radius: 3px;
    border-top-right-radius: 3px;
    border-bottom-right-radius: 3px;
    border-bottom-left-radius: 3px;
    background-color: #fff;
    background-clip: padding-box;
  }

  #popover.mui-popover .mui-scroll .mui-table-view .mui-table-view-cell p {
    margin-bottom: 5px;
    color: #333333;
  }

  #popover.mui-popover .mui-scroll .mui-table-view .mui-table-view-cell .btncommon {
    background-color: #f5f5f5;
    color: #333333;
    border: none;
  }

  #popover.mui-popover .mui-scroll .mui-table-view .mui-table-view-cell .byNum {
    font-size: 14px;
    color: #333333;
    line-height: 2.5;
  }

  #popover.mui-popover .mui-scroll .mui-table-view .mui-table-view-cell .btn_active {
    background-color: #ff5001;
    color: #fff;
  }

  #popover.mui-popover .mui-scroll .mui-table-view .mui-table-view-cell .addnumBox {
    float: right;
  }

  #popover.mui-popover .confirmBtn {
    width: 100%;
    height: 0.75rem;
    margin-top: 0.2rem;
    display: none;
  }

  #popover.mui-popover .confirmBtn input {
    width: 100%;
    height: 100%;
    background-color: #FF5001;
    border: none;
    color: #fff;
    border-radius: 0;
  }

  .hasCollect span {
    color: #FF5001;
  }

</style>
